<template>
  <main>
    <div class="main_item">
      <div class="main_item_title">
        <div class="title">{{ $t('message.cur.main') }}</div>
        <div class="sub_title">{{ $t('message.cur.sub') }}</div>
      </div>
      <div class="card_list">
        <Card v-for="o in curWeb" :key="o.id" v-bind="o" />
      </div>
    </div>
    <div class="main_item">
      <div class="main_item_title">
        <div class="title">{{ $t('message.nominated.main') }}</div>
        <div class="sub_title">{{ $t('message.nominated.sub') }}</div>
      </div>
      <div class="card_list">
        <Card v-for="o in nominated" :key="o.id" v-bind="o" />
      </div>
    </div>
    <div class="main_item">
      <div class="main_item_title">
        <div class="title">{{ $t('message.academy.main') }}</div>
        <div class="sub_title">{{ $t('message.academy.sub') }}</div>
      </div>
      <div class="card_list">
        <Card
          class="card_item"
          v-for="o in academy"
          :key="o.id"
          v-bind="{
            ...o,
            hasSlot: true,
          }"
        >
          <div id="des_box">
            <div class="name">
              How to deliver a highly emotional and interactive experience with
              a low carbon impact
            </div>
            <div class="des">
              <div class="pos">
                {{ $t('message.addTto') }}
                <span class="mark">United Kingdom</span>
              </div>
              <div class="time">{{ curDate }}</div>
            </div>
          </div>
        </Card>
      </div>
    </div>
  </main>
</template>

<script lang="ts" setup>
import { shallowReactive } from 'vue';
import Card from '@/components/card.vue';
import { getHomeData } from './api';
import { convertDayjs } from '@/utils/commonApi';

export interface DataItem {
  id: number | string;
  url: string;
  type: 'img' | 'video';
  canLink: boolean;
  canColl: boolean;
  canRate: boolean;
  canShare: boolean;
  hasTag: boolean;
}
const curDate = convertDayjs();

const curWeb: DataItem[] = shallowReactive([]);
const nominated: DataItem[] = shallowReactive([]);
const academy: DataItem[] = shallowReactive([]);
getHomeData().then((res) => {
  curWeb.push(...(res.curWeb || []));
  nominated.push(...(res.nominated || []));
  academy.push(...(res.academy || []));
});
</script>

<style lang="scss" scoped>
.main_item {
  padding: 0 80px;
  background-color: $body-bg;

  .main_item_title {
    display: flex;
    height: 130px;
    line-height: 130px;
    color: $primary-font-color;
    font-size: 17px;
  }

  .title {
    font-weight: bold;
    font-size: 20px;
    @include ellipsis;
  }

  .sub_title {
    padding-left: 10px;
  }
  .card_list {
    display: flex;
    // justify-content: space-between;
    flex-wrap: wrap;
    margin-right: -3.33%;
    // .card_item {
    //   margin: ;
    // }
  }
  #des_box {
    padding: 20px;
    border-bottom: 1px solid $main-border-color;

    .name {
      color: $primary-font-color;
      line-height: 20px;
      padding-bottom: 20px;
    }

    .des {
      color: #64686a;
      display: flex;
      justify-content: space-between;
      font-size: 16px;
      padding-bottom: 10px;
    }
    .mark {
      color: $second-color;
    }
  }
}
</style>
